function []= convertPlotTotexttable(plotdata,colheaders,rowheaders,filename)
% function to convert a matrix to a pgf plot
% create regular graph, bar charts and table
%the file is saved to filename, data saved with pgf extension, so 
% filename should have a pgf last name. Three different things will be
% created in this file. Bar chart, table and regular plot. No variance is
% added yet
% colheaers is the name of the variable for each column, and rowheaders is
% the name for each test , i.e. the variable name for the row, this graph
% is not really x versus numeric y, but the x  axis are string labels
 
numvariables=size(headers,2);
numtests=size(rowheaders,2);

if(numvariables~=size(plotdata,2) || numtests~=size(plotdata,1))
   error('sizes are incompatible'); 
end

fid = fopen([ filename  ], 'w');
%write table
fprintf(['\begin{tabular}{{{l}*' num2str(numvariables) '}{r}}\n']);

for i=1:numvariables
   fprintf([' & ' colheaders{1,i}]); 
end
fprintf(['\\ \n \hline \n']);

for i=1:numtests
    fprintf([ rowheaders{1,i}]); 
   for j=1:numvariables
     fprintf([' & ' plotdata(i,j)]);
   end
    fprintf(['\\ \n']);
end
fprintf(['\end{tabular}']);

%end of table


fclose(fid);

end